home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / xscalebm / demo9.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-02  |  3.7 KB  |  107 lines

  1. /*************************************************************************
  2.  
  3. DEMO 9
  4.  
  5. Demonstrates Planar Bitmap Scaling/Clipping Functions
  6.  
  7. John Slagel
  8. **************************************************************************/
  9.  
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <conio.h>
  14. #include <ctype.h>
  15. #include <alloc.h>
  16. #include <dos.h>
  17. #include "xlib.h"
  18. #include "xpbitmap.h"
  19. #include "xpbmclip.h"
  20. #include "xrect.h"
  21. #include "xbmtools.h"
  22. #include "xline.h"
  23. #include "xtext.h"
  24. /* Macro to make pointer parameters model independent */
  25. #define FARPTR(x) (MK_FP(FP_SEG(x),FP_OFF(x)))
  26.  
  27. int i,j;
  28.  
  29. char turtle[] = {
  30.     20,30,
  31. /*  |      .       |       .      |       .      |      .       */
  32.     8,14, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  33.     8, 2,14, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  34.     8, 2, 2, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  35.     8, 0, 2,14, 0, 0,14,14,14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  36.     8, 0, 2, 5, 0, 4, 4, 4, 4,14,14, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  37.     8, 0, 2, 2, 4, 4, 0, 4, 4, 0, 4,14, 0, 0, 0, 0, 0, 0, 0, 0,
  38.     0, 0, 2, 4, 4, 4, 0, 4, 4, 0, 4, 4,14, 0, 0, 0, 0, 0, 0, 0,
  39.     0, 0, 2, 4, 4, 4, 0, 0, 0, 0, 4, 4,14, 0, 0, 0, 0, 0, 0, 0,
  40.     0, 0, 0, 0, 4, 0, 4, 4, 4, 0, 0, 0, 4, 0, 0, 2, 2, 0, 0, 0,
  41.     0, 0, 0, 4, 0, 4, 4, 4, 0, 4, 4, 4, 0,14, 0, 0, 2, 2, 0, 0,
  42.     0, 0, 0, 4, 4, 0, 0, 0, 4, 4, 0, 4, 0, 4, 2, 2, 2, 2, 0, 0,
  43.     0, 0, 0, 4, 4, 4, 0, 4, 4, 0, 4, 4, 0, 4,14, 2, 2, 2, 0, 0,
  44.     0, 0, 0, 4, 4, 4, 0, 0, 0, 4, 4, 0, 4, 0, 0, 2, 2, 0, 0, 0,
  45.     0, 0, 0, 2, 4, 4, 4, 4, 4, 4, 4, 0, 4, 4,14, 2, 0, 0, 0, 0,
  46.     0, 0, 2, 2, 0, 4, 4, 4, 4, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0, 0,
  47.     2, 2, 2, 2, 4, 0, 0, 4, 4, 0, 4, 4, 0, 4,14, 0, 0, 0, 0, 0,
  48.     0, 2, 2, 0, 4, 4, 4, 0, 0, 4, 4, 0, 4, 0, 2, 0, 0, 0, 0, 0,
  49.     0, 0, 0, 0, 0, 4, 4, 0, 4, 4, 4, 0, 4, 4, 2,14, 0, 0, 0, 0,
  50.     0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 0, 4, 0, 2, 2,14,14, 0, 0,
  51.     0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 4, 4, 2, 2, 2, 2, 2,14, 0,
  52.     0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 5,14, 0,
  53.     0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 2, 2, 0, 0, 2, 2, 2, 0, 2,14,
  54.     0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 2, 2, 2,14,
  55.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 2, 2, 2,
  56.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 2, 0,
  57.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0,
  58.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0,
  59.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0,
  60.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
  61.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  62.     };
  63.  
  64.  
  65. extern void x_scale_bm(int destx,int desty, int destwidth, int destheight, int scrnoffs, char far * data );
  66.  
  67. char far *vbm;
  68.  
  69. void error(char * string){
  70.   x_text_mode();
  71.   printf("%s\n",string);
  72.   exit(0);
  73. }
  74.  
  75. void main(){
  76.     int i,j,k,handle,size,comp_size;
  77.      char far *bm;
  78.  
  79.      x_text_mode(); /* make sure VGA is in color mode, if possible */
  80.      x_set_mode(X_MODE_360x200,500);           /* actually is set to 496      */
  81.     //x_set_mode(X_MODE_320x200,320);
  82.     ;NonVisual_Offs=16384;
  83.  
  84.     x_text_init();
  85.     x_set_font(FONT_8x15);
  86.     x_bgprintf(0,0,0,14,0," This is a demo of bitmap scaling/clipping.");
  87.  
  88.     bm=FARPTR(turtle);
  89.  
  90.     x_set_cliprect(4,5,50,150);
  91.  
  92.     x_line(0,TopClip-1,320,TopClip-1,23,0);
  93.     x_line(0,BottomClip+1,320,BottomClip+1,23,0);
  94.     x_line((LeftClip<<2)-1,0,(LeftClip<<2)-1,200,23,0);
  95.     x_line((RightClip<<2)+4,0,(RightClip<<2)+4,200,23,0);
  96.  
  97.     getch();
  98.     // Draw bm at (0,0) 160 pixels wide, 100 pixels tall.
  99.     x_scale_bm(0,0,160,100,0,bm);
  100.     getch();                    
  101.  
  102.     x_text_mode();
  103.     printf("%d %d %d %d\n",LeftClip,TopClip,RightClip,BottomClip);
  104.  
  105. }
  106.  
  107.